﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using IQKS.AWP.DataAccessLayer;
using IQKS.AWP.BusinessObject;

namespace IQKS.AWP.BusinessAccessLayer
{
  public  class EmailServerMasterBAL
    {
        public DataSet GetEmailMaster()
        {
            DataSet objDs;
            try
            {
                objDs = new EmailServerMasterDAL().GetEmailMaster(0);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }


        public  EmailServerMasterBO GetEmailMaster(params object[] param)
        {

            EmailServerMasterBO objLMBo;
            try
            {
                objLMBo = new EmailServerMasterBO();
                DataSet objDs;
                objDs = new EmailServerMasterDAL().GetEmailMaster(param);
                if (objDs != null)
                {
                    DataTable objDt = objDs.Tables[0];
                    if (objDt != null)
                    {
                        objLMBo.SmtpServerID = Convert.ToInt32(objDt.Rows[0]["EmailServerID"]);
                        objLMBo.SmtpServerName = Convert.ToString(objDt.Rows[0]["SMTPServer"]);
                        objLMBo.SmtpServerEmail = Convert.ToString(objDt.Rows[0]["SMTPServerEmail"]);
                        objLMBo.SmtpServerPassword=Convert.ToString(objDt.Rows[0]["SMTPServerPassword"]);
                        objLMBo.SiteUrl = Convert.ToString(objDt.Rows[0]["SiteURL"]);
                        objLMBo.IsActive = Convert.ToBoolean(objDt.Rows[0]["IsActive"]);
                    }
                    else
                    {
                        objLMBo = null;
                    }
                }

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objLMBo;
        }


        public object SetEmailMaster(params object[] param)
        {
            try
            {
                return new EmailServerMasterDAL().SetEmailMaster(param);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
    }
}
